	package controllers
	import (
		"github.com/astaxie/beego"
		"fmt"
		"github.com/astaxie/beego/context"
		"net/url"
	)

	type LoginController struct {
		beego.Controller
	}


	func (c * LoginController) Get(){
		c.TplNames="login.html"
	}

	func (c * LoginController) Post(){
		fmt.Println("LoginController Post" )

		c.EnableRender=false

		//参数
		uname := c.Input().Get("uname")
		pwd := c.Input().Get("pwd")
		//keyname :=c.Ctx.Input.GetData("uname")

		fmt.Println("uname=",uname )
		//pwd := c.Input.GetData("pwd")
		fmt.Println("pwd=",pwd)

		//on
		autoLogin := c.Input().Get("autoLogin")

			 if uname==beego.AppConfig.String("uname") && pwd==beego.AppConfig.String("pwd"){
				 maxAge := 0
				 if autoLogin=="on" {
					 maxAge=360;
				 }
				c.Ctx.SetCookie("uname",uname,maxAge,"/")
				c.Ctx.SetCookie("pwd",pwd,maxAge,"/")

				c.Redirect("/",301)
			 }else{
				 c.Ctx.WriteString(uname+"   登陆失败！")
			 }

		//c.Ctx.WriteString(uname+"   "+pwd + autoLogin)
	}



	func CheckAccount(ctx * context.Context, input url.Values) bool{


		key,err := ctx.Request.Cookie("uname")
		if err!=nil {
			return false
		}
		uname:=key.Value

		id,err := ctx.Request.Cookie("pwd")
		if err!=nil {
			return false
		}

		pwd:=id.Value

		return uname==beego.AppConfig.String("uname") && pwd==beego.AppConfig.String("pwd")



	}